package ar.fiuba.logger.formatter;

import java.util.Objects;

import com.google.gson.Gson;

import ar.fiuba.logger.LogFormatterInterface;
import ar.fiuba.logger.LogMessageInterface;

/**
 * The Class LogJSONFormatter.
 */
public class LogJSONFormatter implements LogFormatterInterface {

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object object) {
    if (this == object)
      return true;
    if (object == null)
      return false;
    if (getClass() != object.getClass())
      return false;
    return true;
  }

  /* (non-Javadoc)
   * @see ar.fiuba.logger.LogFormatterInterface#format(ar.fiuba.logger.LogMessageInterface)
   */
  @Override
  public String format(LogMessageInterface logMessage) {

    Gson gson = new Gson();
    String json = gson.toJson(logMessage);

    return json;
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode() {
    return Objects.hashCode(this.getClass());
  }
}
